<template>

      <div v-if="CollectList.length > 0">
        <p style="margin-left:1100px ;">找到相关新闻为{{ CollectList.length }}条</p>
        
        <span v-for="item in CollectList" :key="item.news_id">
          <router-link :to="'/detailPage/' + item.news_id" class="product-link">
            <el-row>
              <el-col :span="3">
                <img :src="item.news_img" style="height: 130px; width: 100%;">
              </el-col>
              <el-col :span="21">
                <el-card class="box-card" style="height: 130px;">
                  <h3>{{ item.news_title }}</h3>
                  <span>{{ item.digest }}</span><br>
                  <!-- <span style="color: gray;">发布者：{{ product.source }}</span><br>
                  <span style="color: gray;">发布时间：{{ product.post_date }}</span> -->
                </el-card></el-col>
            </el-row>
          </router-link>
        </span>
      </div>
      <div v-else>
        <p>没有收藏</p>
      </div>


    



 
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      CollectList:''
    }
  },
  created(){
this.getCollectList()
  },
  computed: {
    ...mapState("user", ["user"]),
  },
  methods: {
    getCollectList() {
      this.axios.get(`http://localhost:3000/users/getNewsCollect?uid=${this.user[0].uid}`).
        then(res => {
          this.CollectList=res.data.data
          // console.log(res.data.data);
        }).catch((err) => {
          console.error(err);
        })
    }
  }

}
</script>

<style></style>